/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;

/**
 *
 * @author fernando
 */
public class AvaliacaoMEC implements Serializable{

    public AvaliacaoMEC (){
        this.pdf = new PDF();
    }
    
    public int getNota() {
        return nota;
    }

    public void setNota(int nota) {
        this.nota = nota;
    }

    public int getAnoInicio() {
        return anoInicio;
    }

    public void setAnoInicio(int anoInicio) {
        this.anoInicio = anoInicio;
    }

    public int getAnoFim() {
        return anoFim;
    }

    public void setAnoFim(int anoFim) {
        this.anoFim = anoFim;
    }

    public PDF getPdf() {
        return pdf;
    }

    public void setPdf(PDF pdf) {
        this.pdf = pdf;
    }
    
    

    @Override
    public boolean equals(Object obj){
        if (obj == null) return false;  
        if (obj.getClass() != this.getClass()) return false;  
        
        if ((this.anoFim == ((AvaliacaoMEC) obj).anoFim) && (this.anoInicio == ((AvaliacaoMEC)obj).anoInicio) &&(this.nota == ((AvaliacaoMEC)obj).nota)) {
            return true;
        }
       
        return false;
         
    }  
    
     public StreamedContent getFile() {  
         System.out.println("Peguei o pdf");
        InputStream stream =  new ByteArrayInputStream(pdf.getConteudo());
        file = new DefaultStreamedContent(stream, "pdf", pdf.getId() + pdf.getNome() + ".pdf" );  
        return file;  
    }    
    
    private StreamedContent file;
    private int nota;
    private int anoInicio;
    private int anoFim;
    private PDF pdf;
    
}
